﻿namespace TanzimSaqib.NoBrainer.Sample.Controllers
{
    using DataAccess;

    public interface IBlogController
    {
        Blog ManagePostsLoad(Blog blog);
    }

    public class BlogController : ControllerBase, IBlogController
    {
        private readonly ISingleRepository _Repository;

        public BlogController()
        {
            if(_Repository == default(ISingleRepository))
            {
                _Repository = new SingleRepository();
            }
        }

        public BlogController(ISingleRepository repository)
        {
            _Repository = repository;
        }

        public Blog ManagePostsLoad(Blog blog)
        {
            blog.PostList = _Repository.GetPosts(blog);
            return blog;
        }
    }
}
